<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ taglib prefix ="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<%@ include file="/common/common-css.jsp" %>
		<style>
		#jquery-table td{cursor:pointer !important}
		.load_bg{background:#000;opacity:0.1;left:0px;top:0px;position:fixed;height:100%;width:100%;overflow:hidden;z-index:10000;}
		.load_img{left:50%;top:180px;position:fixed;height:50px;overflow:hidden;z-index:20000;}
		.datepicker-orient-left{
			display: none !important;
		}
		</style>
	</head>
<body  class="no-skin">
<div  class="load_bg" style="display:none;" ></div>
<img src="http://img.xmiles.cn/commentloading.gif" class="load_img" style="display:none"/>
<div class="page-content">
<div class="page-header" style="margin-bottom:0px;padding-bottom:10px;">
</div>

<form id="queryForm" >
	<div class="page-content-area">
		<div class="row">
			<div class="col-sm-12">
				<div class="widget-box" style="border:0px solid #ccc; border-top:none;border-bottom:none;">
					<div class="widget-header widget-header-blue widget-header-flat">
						<h4 class="widget-title">选择条件进行查询</h4>

						<div class="widget-toolbar">
							<a href="#" data-action="collapse">
								<i class="ace-icon fa fa-chevron-up"></i>
							</a>
						</div>
					</div>

					<div class=" widget-body">
						<!-- <div class="widget-main" style="padding:12px;border:0px solid #ccc; border-top:none;border-bottom:none;"> -->
						<div class="widget-main" >
										<div class="form-group col-xs-12 col-sm-4 col-md-4 col-lg-4">
											<label class="col-sm-4 control-label"  style="text-align:right"  for="sex">时间:</label>
											<div class="col-sm-8">
												<div class="input-daterange input-group">
													<input type="text" data-date-format="yyyy-mm-dd hh:ii" class="fromDate date-picker input-sm form-control" style="padding-left:0px" name="fromDate">
													<span class="input-group-addon" style="width:6px">
														<i class="fa fa-exchange"></i>
													</span>
													<input type="text" data-date-format="yyyy-mm-dd hh:ii" class="endDate date-picker input-sm form-control" style="padding-left:0px" name="endDate">
												</div>
											</div>
										</div>

										 <div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
											<label class="col-sm-4 control-label"  style="text-align:right"  for="prd_name">渠道:</label>
											<div class="col-sm-8" style="padding-left:0;">
												<input type="text" id="channel" name="channel" style="width:100%;text-align:left;">
											</div>
										</div>
										
										
							</div><!-- /.widget-main -->
					</div><!-- /.widget-body -->
				</div><!-- /.widget-box -->
			</div><!-- /.col-sm-12 -->
				<div class="col-md-12 center">
				<div class="clearfix form-actions">
				
					<button class="btn btn-purple  no-border" type="button" name="btn-query" onclick="query_any()" id="btn-query">
						<i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
						查询
					</button>
					&nbsp;&nbsp;&nbsp;
					<button class="btn btn-grey  no-border" type="reset">
						<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
						重置
					</button>
					&nbsp;&nbsp;&nbsp;
					<!-- <button class="btn btn-grey  no-border" type="button" id="exportstatic">
						<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
						导出
					</button> -->
				  </div>
		   </div>
		</div><!-- /.row -->
				 
		<!--highcharts -->		 
		<div class="row" style="margin-bottom:20px;">
			<div id="highcharts-container" class="col-xs-12"></div>
		</div>			 
		
		<div class="row">
			<div class="col-xs-12">
				<table id="jquery-table201" class="table table-striped table-bordered table-hover">			
				</table>
			</div>
		</div>
	</div><!-- /.page-content-area -->
	
	</form>

<!-- 	<form enctype="multipart/form-data" method="post" id="uploadForm" class="form-horizontal" name="uploadForm">
		<label for="uploadExcel">上传excel文件</label>
		<input type="file" name="excelFile" class="input" id="excelFile" />
		<input type="button" value="上传" id="uploadFile" onclick="uploadExcelFile()"><br/>
    </form> -->
	
</div><!-- /.page-content -->

<%@ include file="/common/common-js.jsp" %>
<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery.form.js"></script>
<!-- inline scripts related to this page -->
<script type="text/javascript">

jQuery(function($) {
	//日期时间插件
	$('.date-picker').datetimepicker({
		  	language:  'zh-CN',
	        todayBtn:  1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			minView:2,
			forceParse: 0,
			showMeridian: 1,
			format: 'yyyy-mm-dd'
	}).next().on(ace.click_event, function(){
		$(this).prev().focus();
	});
	
	$("#uploadForm").submit(function(){ 
        $(this).ajaxSubmit({  
            type:"post",  //提交方式  
            dataType:"json", //数据类型  
            url:ctx+"/statics/worthbuying/uploadExcelFile.action", //请求url  
            success:function(data){ //提交成功的回调函数  
                alert(data.responseText);
                $("#uploadForm")[0].reset(); // 提交后重置表单
            },
            error : function(data){ //提交成功的回调函数  
                alert(data.responseText);  
                $("#uploadForm")[0].reset(); // 提交后重置表单
            }
        });  
        return false; //不刷新页面  
    });
	
});

function query_any(){
	  
	platform = $('#platform').val();
  	var statisticstype = $('#statisticstype').val();
    loaddata(statisticstype); 
}

var jqTable201 = null;
	
var loaddata = function(searchType,interface_id){
	jQuery(function($) {
	  $('.dataTables_wrapper').css('display', 'none');
      //详情统计
      if (jqTable201 != null) {
  	  $('#jquery-table201_wrapper').css('display','block');
  	  jqTable201.fnDraw();
  	  		return;
  	  		}
        	jqTable201 = $('#jquery-table201').dataTable( {
        		"columnDefs": [
  		    	
  		    	{
  		    		  "title":"渠道名称",
  		    		  "name":"channel",
  		    		  "data": "channel",
  		    	  	  "targets": [0], 
  		    	  	  "bSortable": true,
   		    	  	  "width": "18%"
  		    	},
  		    	 {
  		    	 	  "title":"渠道号",
  		    	 	  "name":"channelCode",
  		    	 	  "data": "channelCode",
  		    	  	  "targets": [1],
  		    	 	  "bSortable": true,
   		    	 	  "width": "18%",
  		    	},
  		    	{
  		    		  "title":"用户总量",
  		    		  "name":"count",
  		    		  "data": "count",
  		    	  	  "targets": [2], 
  		    	  	  "bSortable": true,
   		    	  	  "width": "18%"
  		    	},
  		    	 
  		    	 
  		  	],
  			"sAjaxSource": ctx+"/statics/dailyreport/dailyReportList.action",
  			"fnServerData": function ( sSource, aoData, fnCallback ) {//从服务器请求数据
  		   			/* var data = $('#queryForm').serializeObject();
  					aoData = JSON.stringify(aoData).replace(new RegExp("\/\/","gm"),"");
  		   			aoData = JSON.parse(aoData);
  		   			data.aoData = aoData;
  		   			var test =  JSON.stringify(data);
  					test = test.slice(1,test.length);
  					var fromDate = $('.fromDate').val();
  					var endDate = $('.endDate').val(); */
  					
  					var data = $('#queryForm').serializeObject();
					data.aoData = JSON.stringify(aoData);
  					$.ajax({
  						"type": "POST",
  						"dataType": 'json',
  						"url": sSource,
  						"data": data,
						"beforeSend": function() {
							// 显示loading
							$(".load_bg,.load_img").show();
						},
  						"success": function(resp){
  						    console.log(resp);
  							fnCallback(resp);
  							initListPage();
							
							/* //生成图表
							var highchartsData = new Array();
							var allNum = Number(resp.total);
							var Num7 = 0;
							$.each(resp.aaData,function(index,item){
								if(index<7){
								    Num7 += Number(item.d8);
									var a = [item.name,item.d8];
									highchartsData.push(a);
								};
							});
						    var otherNum = allNum - Num7;
							var b = ['其他',otherNum];
							highchartsData.push(b);
							getHighcharts(highchartsData); */
							
  						},		
  						"error": function(XMLHttpRequest, textStatus, errorThrown) {
  						},
  						 complete:function(){
						    $('.load_bg,.load_img').hide();
						} 				
  				  });
                    $.ajaxSetup({ 
                        xhrFields: { withCredentials: false }, 
                        crossDomain: true 
                    });
  			},
  			"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
  				nRow.ondblclick = function() {
					var channelCode = aData["channelCode"];
					var url = "/statics/dailyreport/singleDailyReportList.action?channelCode="+ channelCode;
					url = encodeURI(url);
					openDialogWithRand(url,1400,1000,aData["channel"],function (data){});
				};
  			},
  			"sScrollXInner": "100%",
  			"bRetrieve": true,
  			"sScrollY": "100%",//如果不设置，IE会有问题
  		    "aaSorting": [[1,"desc"]] 
        	});
	});
}

/* function successCallback(responseText) {
	alert(responseText);
} */
function uploadExcelFile() {
	$("#uploadForm").submit();
	
	/* $("#uploadForm").attr("action",ctx+"/statics/worthbuying/uploadExcelFile.action");  
	var options = { 
            dataType: 'json',
            success: successCallback
    };
    $("#uploadForm").ajaxSubmit(options); */
    
}
	
</script>
		
</body>
</html>
